package net.qiqbframework.modelling.domain;


import net.qiqbframework.messaging.MetaData;

import static net.qiqbframework.modelling.domain.AggregateLifecycle.getInstance;

public interface AggregateContext {


    static void addEvent(Object payload, MetaData metaData) {
        getInstance().doApply(payload, metaData);
    }


    static void addEvent(Object payload) {
        getInstance().doApply(payload, MetaData.emptyInstance());
    }

    static void addEvents(Object... payloads) {
        for (Object payload : payloads) {
            getInstance().doApply(payload, MetaData.emptyInstance());
        }

    }


    static boolean isLive() {
        return getInstance().getIsLive();
    }

    static boolean isDeleted() {
        return getInstance().isDeleted();
    }

    static boolean isNew() {
        return getInstance().isNew();
    }


    static Long getVersion() {
        return getInstance().version();
    }

    static Object getAggregateRoot() {
        return getInstance().aggregateRoot();
    }


    static void markDeleted() {
        getInstance().doMarkDeleted();
    }

    static void markNew() {
        getInstance().doMarkNew();
    }

    static void markNotNew() {
        getInstance().doMarkNotNew();
    }


}
